/*
 * @(#)SCSView.java		       Project:SpikeSC
 * Date:2012-7-24
 *
 * Copyright (c) 2011 CFuture09, Institute of Software, 
 * Guangdong Ocean University, Zhanjiang, GuangDong, China.
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.sinaapp.msdxblog.spikesc.ui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;

import org.dyno.visual.swing.layouts.Bilateral;
import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;

import com.sinaapp.msdxblog.spikesc.vo.SpikeUser;

//VS4E -- DO NOT REMOVE THIS LINE!
/**
 * @author Geek_Soledad (66704238@51uc.com)
 */
public class SCSView extends JFrame {

	private static final long serialVersionUID = 1L;
	private JLabel jLUser;
	private JLabel jLWelcome;
	private JPanel jPTop;
	private JSplitPane jSplitPane;
	private SpikeUser mSpikeUser;
	private JTree jTree0;
	private JScrollPane jScrollPane;
	private JPanel jPanelQuery;
	private JPanel jPanelUpdate;
	private JPanel jPanelUser;
	private JPanel jPanelLog;
	
	private JLabel jLabel0;
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JButton jButton0;
	private JComboBox jComboBox0;
	private JComboBox jComboBox1;
	private JComboBox jComboBox2;
	private JTable jTable0;
	private JScrollPane jScrollPane0;
	private static final String PREFERRED_LOOK_AND_FEEL = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
	public SCSView(SpikeUser spikeUser) {
		mSpikeUser = spikeUser;
		initComponents();
	}

	public SCSView() {
		initComponents();
	}

	private void initComponents() {
		setTitle("斯派克库存管理系统");
		add(getJPTop(), BorderLayout.NORTH);
		add(getJSplitPane(), BorderLayout.CENTER);
		setSize(771, 376);
	}

	private JScrollPane getJScrollPane0() {
		if (jScrollPane0 == null) {
			jScrollPane0 = new JScrollPane();
			jScrollPane0.setViewportView(getJTable0());
		}
		return jScrollPane0;
	}

	private JTable getJTable0() {
		if (jTable0 == null) {
			jTable0 = new JTable();
			jTable0.setModel(new DefaultTableModel(new Object[][] { { "0x0", "0x1", }, { "1x0", "1x1", }, }, new String[] { "Title 0", "Title 1", }) {
				private static final long serialVersionUID = 1L;
				Class<?>[] types = new Class<?>[] { Object.class, Object.class, };
	
				public Class<?> getColumnClass(int columnIndex) {
					return types[columnIndex];
				}
			});
		}
		return jTable0;
	}

	private JComboBox getJComboBox2() {
		if (jComboBox2 == null) {
			jComboBox2 = new JComboBox();
			jComboBox2.setModel(new DefaultComboBoxModel(new Object[] { "item0", "item1", "item2", "item3" }));
		}
		return jComboBox2;
	}

	private JComboBox getJComboBox1() {
		if (jComboBox1 == null) {
			jComboBox1 = new JComboBox();
			jComboBox1.setModel(new DefaultComboBoxModel(new Object[] { "item0", "item1", "item2", "item3" }));
		}
		return jComboBox1;
	}

	private JComboBox getJComboBox0() {
		if (jComboBox0 == null) {
			jComboBox0 = new JComboBox();
			jComboBox0.setModel(new DefaultComboBoxModel(new Object[] { "item0", "item1", "item2", "item3" }));
		}
		return jComboBox0;
	}

	private JButton getJButton0() {
		if (jButton0 == null) {
			jButton0 = new JButton();
			jButton0.setText("查询");
		}
		return jButton0;
	}

	private JLabel getJLabel2() {
		if (jLabel2 == null) {
			jLabel2 = new JLabel();
			jLabel2.setText("颜色");
		}
		return jLabel2;
	}

	private JLabel getJLabel1() {
		if (jLabel1 == null) {
			jLabel1 = new JLabel();
			jLabel1.setText("类型");
		}
		return jLabel1;
	}

	private JLabel getJLabel0() {
		if (jLabel0 == null) {
			jLabel0 = new JLabel();
			jLabel0.setText("产品");
		}
		return jLabel0;
	}

	private JPanel getJPanelQuery() {
		if (jPanelQuery == null) {
			jPanelQuery = new JPanel();
			jPanelQuery.setLayout(new GroupLayout());
			jPanelQuery.add(getJLabel0(), new Constraints(new Leading(24, 12, 12), new Leading(27, 10, 10)));
			jPanelQuery.add(getJLabel1(), new Constraints(new Leading(187, 12, 12), new Leading(27, 13, 13)));
			jPanelQuery.add(getJLabel2(), new Constraints(new Leading(330, 12, 12), new Leading(27, 13, 13)));
			jPanelQuery.add(getJButton0(), new Constraints(new Leading(502, 10, 10), new Leading(24, 13, 13)));
			jPanelQuery.add(getJComboBox0(), new Constraints(new Leading(55, 120, 12, 12), new Leading(24, 13, 13)));
			jPanelQuery.add(getJComboBox1(), new Constraints(new Leading(216, 99, 12, 12), new Leading(24, 13, 13)));
			jPanelQuery.add(getJComboBox2(), new Constraints(new Leading(362, 109, 10, 10), new Leading(24, 13, 13)));
			jPanelQuery.add(getJScrollPane0(), new Constraints(new Bilateral(27, 12, 23), new Leading(55, 269, 10, 10)));
		}
		return jPanelQuery;
	}

	private JPanel getJPanelUpdate() {
		if (jPanelUpdate == null) {
			jPanelUpdate = new JPanel();
			jPanelUpdate.setLayout(new GroupLayout());
		}
		return jPanelUpdate;
	}
	private JPanel getJPanelUser() {
		if (jPanelUser == null) {
			jPanelUser = new JPanel();
			jPanelUser.setLayout(new GroupLayout());
		}
		return jPanelUser;
	}
	private JPanel getJPanelLog() {
		if (jPanelLog == null) {
			jPanelLog = new JPanel();
			jPanelLog.setLayout(new GroupLayout());
		}
		return jPanelLog;
	}

	private JScrollPane getJScrollPane() {
		if (jScrollPane == null) {
			jScrollPane = new JScrollPane();
			jScrollPane.setViewportView(getJTree0());
		}
		return jScrollPane;
	}

	private JTree getJTree0() {
		if (jTree0 == null) {
			jTree0 = new JTree();
			DefaultTreeModel treeModel = null;
			{
				DefaultMutableTreeNode node0 = new DefaultMutableTreeNode("库存管理系统");
				{
					DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("库存查询");
					node0.add(node1);
				}
				{
					DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("出入库管理");
					node0.add(node1);
				}
				{
					DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("用户管理");
					node0.add(node1);
				}
				{
					DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("日志管理");
					node0.add(node1);
				}
				treeModel = new DefaultTreeModel(node0);
			}
			jTree0.setModel(treeModel);
		}
		return jTree0;
	}

	private JSplitPane getJSplitPane() {
		if (jSplitPane == null) {
			jSplitPane = new JSplitPane();
			jSplitPane.setDividerLocation(160);
			jSplitPane.setLeftComponent(getJScrollPane());
			jSplitPane.setRightComponent(getJPanelQuery());
		}
		return jSplitPane;
	}

	private JPanel getJPTop() {
		if (jPTop == null) {
			jPTop = new JPanel();
			jPTop.setLayout(new FlowLayout(FlowLayout.LEFT));
			jPTop.setPreferredSize(new Dimension(100, 40));
			jPTop.add(getJLUser());
			jPTop.add(getJLWelcome());
		}
		return jPTop;
	}

	private JLabel getJLWelcome() {
		if (jLWelcome == null) {
			jLWelcome = new JLabel();
			jLWelcome.setText("，欢迎使用斯派克库存管理系统！");
		}
		return jLWelcome;
	}

	private JLabel getJLUser() {
		if (jLUser == null) {
			jLUser = new JLabel();
			if (mSpikeUser != null) {
				jLUser.setText(mSpikeUser.getUsername());
			}
		}
		return jLUser;
	}

	private static void installLnF() {
		try {
			String lnfClassname = PREFERRED_LOOK_AND_FEEL;
			UIManager.setLookAndFeel(lnfClassname);
		} catch (Exception e) {
			System.err.println("Cannot install " + PREFERRED_LOOK_AND_FEEL
					+ " on this platform:" + e.getMessage());
		}
	}

	/**
	 * Main entry of the class. Note: This class is only created so that you can
	 * easily preview the result at runtime. It is not expected to be managed by
	 * the designer. You can modify it as you like.
	 */
	public static void main(String[] args) {
		installLnF();
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				SCSView frame = new SCSView();
				frame.setDefaultCloseOperation(SCSView.EXIT_ON_CLOSE);
				frame.setTitle("SCSView");
				frame.getContentPane().setPreferredSize(frame.getSize());
				frame.pack();
				frame.setLocationRelativeTo(null);
				frame.setVisible(true);
			}
		});
	}
}
